{% extends "./base_index.html" %}

<!-- 功能网页的模版 -->
{% block modal %}
{% endblock %}

{% block fenye %}
{% endblock %}


{% block content %}

<!-- 按钮点击事件  -->

  <div class="container">
    <div class="row">
     <!-- 表单 -->
      <div class="col-md-7">
        {% block form %}
        <form role="form"> 
          <div class="form-group">
            <span class="help-block">{% block span_text %}Struts2_045在线检测{% endblock %}</span><!--span text继承-->
            <input class="form-control" type="text" name="content" id="content" placeholder="{% block pla %}请输入URL http://thief.one{% endblock %}">
          </div>
          {% block form_button %} <!--form 按钮继承-->
          <p> <span id="result"></span> </p>
          <button class="btn btn-primary btn-bl" type="button" id='runing' data-loading-text="Loading加载中..." autocomplete="off" onclick="loag()">运行</button>

          {% endblock %}
        </form>
         {% endblock %}
      </div>

      <!-- 帮助信息  -->
      <div class="col-md-4 col-md-offset-1">
          <span class="help-block">帮助信息栏</span>
          <hr>
          {% block help %}{% endblock %} <!--帮助信息继承-->
      </div>
    </div>
  </div>
<br>


<!-- ajax -->

<script>
$.ajaxSetup({
    data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
});
</script>


{% block ajax %} <!--ajax继承-->
<script>
    $(document).ready(function(){
      $("#runing").click(function(){
        var content = $("#content").val();
        var btn = $("#runing");

        btn.button('loading');
 
        $.post("{% url 'struts2_045_ajax' %}",{'content':content}, function(ret){
            // document.getElementById('content').value = ret
            $('#result').html(ret)

            btn.button('reset');
        });

      });

    });

    
</script>
{% endblock %}

{% endblock %}
